#include "game_background.h"

Game_Background::Game_Background(Sence_Config* config){
	this->currentPic = 0;
	this->timer_tick = 0;
	this->p_config = config;
	Game_Part::LoadPicture(this->pictures,this->p_config->Background_Num,this->p_config->BackgroundFolder);
}

Game_Background::~Game_Background(){
	Game_Part::Destroy(this->pictures);
}

bool Game_Background::TimerTick(){
	bool flag = false;
	++ this->timer_tick;
	if(!(this->timer_tick % this->p_config->Background_Tick_Num)){
		++this->currentPic;
		this->currentPic = this->currentPic % this->p_config->Background_Num;
		flag = true;
	}
	return flag;
}

void Game_Background::UpdateToScreen(){
	SDL_Surface* screen = UI::UI_Application::Instance()->GetAppScreen();
	SDL_Surface* p = this->pictures[this->currentPic];
	SDL_Rect r;
	r.x = 0;
	r.y = 0;
	r.w = p->w;
	r.h = p->h;
	SDL_BlitSurface(p,NULL,screen,&r);
}